package mvc;

import java.io.IOException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.apache.shiro.SecurityUtils;
import org.omnifaces.util.Faces;

/**
 *
 * @author tadiwa
 */
@ManagedBean
@RequestScoped
public class Logout {

    public Logout() {
    }
    public static final String LOGIN_URL = "/yapp/faces/login.xhtml";

    public void submit() throws IOException {
        //log.info("user logout " + SecurityUtils.getSubject().getPrincipal().toString());
        SecurityUtils.getSubject().logout();
        Faces.invalidateSession();
        Faces.redirect(LOGIN_URL);
      //  System.out.println(SecurityUtils.getSubject().getPrincipal().toString()+"....invoked logout action.");
    }

}
